<?php
ss_error::group('Slipstream config');
ss_error::group('Dependency Injector setup');
	require_once 'Bucket/bucket.inc.php';
	if(class_exists('site_bucket_factory')){
		$factory=new site_bucket_factory($ss);
	} else {
		$factory=new ss_bucket_factory($ss);
	};
	$injector=new ss_bucket_injector($factory);
	$injector->registerImplementation('ss_core_configInterface','site_core_config');
	$injector->set($ss);
	//ss_error::log($injector,'Injector');
ss_error::groupEnd();
if($ss['doctrine']['active']){
	ss_error::group('Doctrine setup');
	define('SS_DOCTRINE_PATH',SS_ROOT_PATH.DIRECTORY_SEPARATOR.$ss['doctrine']['version']);
	define('SS_DOCTRINE_DATA_FIXTURES_PATH',SS_DOCTRINE_PATH.DIRECTORY_SEPARATOR.'data'.DIRECTORY_SEPARATOR.'fixtures');
	define('SS_DOCTRINE_MODELS_PATH',SS_DOCTRINE_PATH.DIRECTORY_SEPARATOR.'models');
	define('SS_DOCTRINE_MIGRATIONS_PATH',SS_DOCTRINE_PATH.DIRECTORY_SEPARATOR.'migrations');
	define('SS_DOCTRINE_SQL_PATH',SS_DOCTRINE_PATH.DIRECTORY_SEPARATOR.'sql');
	define('SS_DOCTRINE_SCHEMA_PATH',SS_DOCTRINE_PATH.DIRECTORY_SEPARATOR.'schema');
	$injector->set($manager = Doctrine_Manager::getInstance());
	//$manager->setAttribute(Doctrine::ATTR_VALIDATE, Doctrine::VALIDATE_ALL);
	$manager->setAttribute(Doctrine::ATTR_EXPORT, Doctrine::EXPORT_ALL);
	//$manager->setAttribute(Doctrine::ATTR_AUTO_ACCESSOR_OVERRIDE, true);
	$manager->setAttribute(Doctrine::ATTR_AUTOLOAD_TABLE_CLASSES, true);
	$manager->setAttribute(Doctrine::ATTR_MODEL_LOADING, Doctrine::MODEL_LOADING_CONSERVATIVE);
	$manager->setAttribute(Doctrine::ATTR_PORTABILITY, 'none');
	$manager->setAttribute(Doctrine::ATTR_QUOTE_IDENTIFIER , true);
	$manager->setAttribute(Doctrine::ATTR_AUTOLOAD_TABLE_CLASSES , true);
	$manager->setCollate('utf8_swedish_ci');
    $manager->setCharset('UTF8');
	$manager->setAttribute(Doctrine::ATTR_DEFAULT_TABLE_CHARSET,'utf8');
	$manager->setAttribute(Doctrine::ATTR_DEFAULT_TABLE_COLLATE,'utf8_swedish_ci');
	if($ss['doctrine']['version']=='doctrine12'){
		ss_error::log('loading with doctrine 1.2');
		$manager->setAttribute(Doctrine::ATTR_TABLE_CLASS, 'ss_doctrine_table');
		$manager->setAttribute(Doctrine::ATTR_QUERY_CLASS, 'ss_doctrine_query');
		$manager->setAttribute(Doctrine::ATTR_COLLECTION_CLASS, 'ss_doctrine_collection');
		$manager->registerHydrator('jsonRef', 'ss_doctrine_jsonrefhydrator');
	}
	$_cstring=$ss['dao']['default']['type'].'://'.
		$ss['dao']['default']['user'].':'.
		$ss['dao']['default']['pass'].'@'.
		$ss['dao']['default']['host'].'/'.
		$ss['dao']['default']['database']/*.
		'?charset=utf8'*/;
	if(isset($ss['dao']['default']['unix_socket'])) $_cstring.=";unix_socket={$ss['dao']['default']['unix_socket']}";
	$injector->set($conn = Doctrine_Manager::connection($_cstring, $ss['dao']['default']['database']));
	$conn->setCharset('UTF8');
	$conn->setCollate('utf8_swedish_ci');
	$conn->setAttribute(Doctrine::ATTR_USE_NATIVE_ENUM, true);
	//$conn->setCharset(’UTF8′);
	ss_error::log(SITE_DOCTRINE_MODELS_PATH,'Models path');
	//ss_error::warn(class_exists('User',true));
	//require_once('D:\Work\hamilton\svn\trunk\doctrine12\models\User.php');
	//ss_error::log(Doctrine::loadModels(SITE_DOCTRINE_MODELS_PATH));
	//ss_error::warn(class_exists('User',false));
	ss_error::groupEnd();
}
ss_error::groupEnd();
?>